import { Document, PhoneFilled, Plus, UserFilled, Clock, Avatar, TrendCharts, HelpFilled, List, Management, GoodsFilled, BrushFilled, ShoppingCartFull, Opportunity, Histogram, EditPen, CircleCheckFilled, Comment, Edit, Refresh, Switch, Grid, Briefcase, Check, ShoppingCart, ShoppingBag, Van, Bicycle, Upload, Download, Tickets, Sort } from '@element-plus/icons-vue';
import cookie from 'js-cookie';
import { jwtDecode } from 'jwt-decode';
//组长说权限写简单亿点点，就这么写了
//
interface Decode {
	username : string;
	user_id : string | number,
}
//
// admin权限
const adminList = [{
	title: '公司管理',
	isShow: true,
	size: '12px',
	list: [{
		icon: Avatar,
		text: '经营看板',
		path: ''
	}, {
		icon: HelpFilled,
		text: '产品追踪',
		path: '/f-products'
	}, {
		icon: TrendCharts,
		text: '客户分析',
		path: '/f-client'
	},]
}, {
	title: '客户管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: UserFilled,
		color: '#42b33e',
		text: '客户信息',
		path: '/s-client'
	}, {
		icon: PhoneFilled,
		color: '#82b51b',
		text: '客户跟进',
		path: 's-client-g'
	},]
}, {
	title: '销售订单',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: List,
		color: '#42b33e',
		text: '订单信息',
		path: '/ordersInfo'
	}, {
		icon: Document,
		color: '#82b51b',
		text: '订单明细',
		path: 'ordersDetail'
	},]
}, {
	title: '销售发货',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: Check,
		color: '#42b33e',
		text: '发货单',
		path: '/shipmentSingle'
	}, {
		icon: Check,
		color: '#82b51b',
		text: '发货明细',
		path: '/shipmentDetail'
	},]
}, {
	title: '销售退货',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: Grid,
		color: '#5283ff',
		text: '退货单',
		path: '/returnOrder'
	}, {
		icon: Grid,
		color: '#5283ff',
		text: '退货明细',
		path: '/returnOrderDetail'
	},]
}, {
	title: '采购管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: ShoppingCartFull,
		color: '#fa9e00',
		text: '采购需求',
		path: '/procurementDemand'
	}, {
		icon: ShoppingCart,
		color: '#fa9e00',
		text: '采购订单',
		path: '/procurementOrders'
	}, {
		icon: ShoppingBag,
		color: '#fa9e00',
		text: '采购明细',
		path: '/procurementDetail'
	}, {
		icon: UserFilled,
		color: '#fa9e00',
		text: '供应商管理',
		path: '/vendorManage'
	},]
}, {
	title: '采购到货',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: Van,
		color: '#fa9e00',
		text: '采购到货单',
		path: '/procurementList'
	}, {
		icon: Bicycle,
		color: '#fa9e00',
		text: '到货明细',
		path: '/receiptDetail'
	}]
}, {
	title: '库存管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: GoodsFilled,
		color: '#5283ff',
		text: '库存表',
		path: '/inventoryTable'
	}, {
		icon: List,
		color: '#5283ff',
		text: '库存盘点',
		path: '/inventoryInventory'
	}]
}, {
	title: '出入库管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: Upload,
		color: '#fbaa00',
		text: '出库单',
		path: ''
	}, {
		icon: Grid,
		color: '#fbaa00',
		text: '出库明细',
		path: ''
	}, {
		icon: Download,
		color: '#42b33e',
		text: '入库单',
		path: ''
	}, {
		icon: Grid,
		color: '#42b33e',
		text: '入库明细',
		path: ''
	}]
}, {
	title: '收支管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: Plus,
		color: '#42b33e',
		text: '销售收款',
		path: '/salesCollections'
	}, {
		icon: CircleCheckFilled,
		color: '#fa9e00',
		text: '采购付款',
		path: '/purchasePayments'
	}]
}, {
	title: '发票管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: Tickets,
		color: '#40bd93',
		text: '销项发票',
		path: ''
	}, {
		icon: Document,
		color: '#40bd93',
		text: '进项发票',
		path: ''
	}]
}, {
	title: '对账管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: List,
		color: '#5283ff',
		text: '应收/应付明细',
		path: ''
	}, {
		icon: Refresh,
		color: '#42b382',
		text: '客户对账单',
		path: ''
	}, {
		icon: Grid,
		color: '#60b33e',
		text: '客户对账明细',
		path: ''
	}, {
		icon: Sort,
		color: '#fa9e00',
		text: '供应商对账单',
		path: ''
	}, {
		icon: Grid,
		color: '#fa9e00',
		text: '供应商对账明细',
		path: ''
	}]
}];
// 销售权限
const xsList = [{
	title: '公司管理',
	isShow: true,
	size: '12px',
	list: [{
		icon: Avatar,
		text: '经营看板',
		path: ''
	}, {
		icon: HelpFilled,
		text: '产品追踪',
		path: '/f-products'
	}, {
		icon: TrendCharts,
		text: '客户分析',
		path: '/f-client'
	},]
}, {
	title: '客户管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: UserFilled,
		color: '#42b33e',
		text: '客户信息',
		path: '/s-client'
	}, {
		icon: PhoneFilled,
		color: '#82b51b',
		text: '客户跟进',
		path: 's-client-g'
	},]
}, {
	title: '销售订单',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: List,
		color: '#42b33e',
		text: '订单信息',
		path: '/ordersInfo'
	}, {
		icon: Document,
		color: '#82b51b',
		text: '订单明细',
		path: 'ordersDetail'
	},]
}, {
	title: '销售发货',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: Check,
		color: '#42b33e',
		text: '发货单',
		path: '/shipmentSingle'
	}, {
		icon: Check,
		color: '#82b51b',
		text: '发货明细',
		path: '/shipmentDetail'
	},]
}, {
	title: '销售退货',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: Grid,
		color: '#5283ff',
		text: '退货单',
		path: '/returnOrder'
	}, {
		icon: Grid,
		color: '#5283ff',
		text: '退货明细',
		path: '/returnOrderDetail'
	},]
},];
//采购权限
const cgList = [{
	title: '公司管理',
	isShow: true,
	size: '12px',
	list: [{
		icon: Avatar,
		text: '经营看板',
		path: ''
	}, {
		icon: HelpFilled,
		text: '产品追踪',
		path: '/f-products'
	}, {
		icon: TrendCharts,
		text: '客户分析',
		path: '/f-client'
	},]
}, {
	title: '采购管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: ShoppingCartFull,
		color: '#fa9e00',
		text: '采购需求',
		path: '/procurementDemand'
	}, {
		icon: ShoppingCart,
		color: '#fa9e00',
		text: '采购订单',
		path: '/procurementOrders'
	}, {
		icon: ShoppingBag,
		color: '#fa9e00',
		text: '采购明细',
		path: '/procurementDetail'
	}, {
		icon: UserFilled,
		color: '#fa9e00',
		text: '供应商管理',
		path: '/vendorManage'
	},]
}, {
	title: '采购到货',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: Van,
		color: '#fa9e00',
		text: '采购到货单',
		path: '/procurementList'
	}, {
		icon: Bicycle,
		color: '#fa9e00',
		text: '到货明细',
		path: '/receiptDetail'
	}]
},];
//库存权限 
const kcList = [{
	title: '公司管理',
	isShow: true,
	size: '12px',
	list: [{
		icon: Avatar,
		text: '经营看板',
		path: ''
	}, {
		icon: HelpFilled,
		text: '产品追踪',
		path: '/f-products'
	}, {
		icon: TrendCharts,
		text: '客户分析',
		path: '/f-client'
	},]
}, {
	title: '库存管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: GoodsFilled,
		color: '#5283ff',
		text: '库存表',
		path: '/inventoryTable'
	}, {
		icon: List,
		color: '#5283ff',
		text: '库存盘点',
		path: '/inventoryInventory'
	}]
}, {
	title: '出入库管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: Upload,
		color: '#fbaa00',
		text: '出库单',
		path: ''
	}, {
		icon: Grid,
		color: '#fbaa00',
		text: '出库明细',
		path: ''
	}, {
		icon: Download,
		color: '#42b33e',
		text: '入库单',
		path: ''
	}, {
		icon: Grid,
		color: '#42b33e',
		text: '入库明细',
		path: ''
	}]
},];
//财务财务
const cwList = [{
	title: '公司管理',
	isShow: true,
	size: '12px',
	list: [{
		icon: Avatar,
		text: '经营看板',
		path: ''
	}, {
		icon: HelpFilled,
		text: '产品追踪',
		path: '/f-products'
	}, {
		icon: TrendCharts,
		text: '客户分析',
		path: '/f-client'
	},]
}, {
	title: '收支管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: Plus,
		color: '#42b33e',
		text: '销售收款',
		path: '/salesCollections'
	}, {
		icon: CircleCheckFilled,
		color: '#fa9e00',
		text: '采购付款',
		path: '/purchasePayments'
	}]
}, {
	title: '发票管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: Tickets,
		color: '#40bd93',
		text: '销项发票',
		path: ''
	}, {
		icon: Document,
		color: '#40bd93',
		text: '进项发票',
		path: ''
	}]
}, {
	title: '对账管理',
	isShow: false,
	icon: Briefcase,
	color: '#666',
	list: [{
		icon: List,
		color: '#5283ff',
		text: '应收/应付明细',
		path: ''
	}, {
		icon: Refresh,
		color: '#42b382',
		text: '客户对账单',
		path: ''
	}, {
		icon: Grid,
		color: '#60b33e',
		text: '客户对账明细',
		path: ''
	}, {
		icon: Sort,
		color: '#fa9e00',
		text: '供应商对账单',
		path: ''
	}, {
		icon: Grid,
		color: '#fa9e00',
		text: '供应商对账明细',
		path: ''
	}]
}];
// 定义菜单列表映射对象
const menuLists = {
	admin: adminList,//系统管理员
	xs: xsList,//销售
	cg: cgList,//采购
	kc: kcList,//库存
	cw: cwList,//财务
}
export function getMenuList() {
	const token = cookie.get('token');
	const decodedToken : Decode = jwtDecode(token);
	const type = decodedToken.username;

	// 检查从 token 中解析出的用户类型是否存在于 menuLists 中
	if (menuLists.hasOwnProperty(type)) {
		return menuLists[type];
	} else {
		// 处理未识别的用户类型
		console.warn(`未识别的用户类型: ${type}`);
		return []; // 或者返回默认的菜单列表，或者抛出错误，视应用需求而定
	}
}